package com.ccs.testcase;

import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.openqa.selenium.WebDriver;

import com.ccs.functions.*;
import com.ccs.transmittal.*;


@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class Transmittal_Include {

	private static WebDriver driver;
	public static String transmittal_number;
	public static double transmittal_amount;
	
	static
	Webdriver d = new Webdriver();
	Login in = new Login();
	Misc_Transmittal m = new Misc_Transmittal();
	Admin_Transmittal_List atl = new Admin_Transmittal_List();
	Admin_Create_Transmittal_List actl = new Admin_Create_Transmittal_List();
	
	@BeforeClass
	public static void startBrowser()throws Exception{
		driver = d.startUp();
	}
	@Test
	public void a_login_app() throws Exception{
		System.out.println("Start Test: Login Admin Console");
		m.maximize_window(driver);
		in.admin(driver);
		System.out.println("End Test: Login Admin Console\n");
	}
	@Test
	public void b_display_transmittal_list_admin() throws Exception{
		System.out.println("Start Test: Goto Transmittal List");
		m.go_to_transmittal_admin(driver);
		m.go_to_create_transmittal(driver);
		System.out.println("End Test: Goto Transmittal List\n");
	}
	@Test
	public void c_search_transmittal_manual() throws Exception{
		System.out.println("Start Test: Search for SOA/CI Discharged Yesterday");
		transmittal_number = actl.search_and_generate_soa_ci(driver, "COCOLIFE HEALTH CARE", "6/13/2014");
		System.out.println("End Test: Search for SOA/CI Discharged Yesterday\n");
	}
	@Test
	public void d_verify_transmittal_table_headers() throws Exception{
		System.out.println("Start Test: Verify Transmittal Table Headers");
		actl.verify_transmittal_table_headers(driver,false);
		System.out.println("End Test: Verify Transmittal Table Headers\n");
	}
	@Test
	public void e_transmittal_table() throws Exception{
		System.out.println("Start Test: Create Visit Number Array");
		actl.create_and_verify_tables(driver, false);
		System.out.println("End Test: Create Visit Number Array\n");
	}	
	@Test
	public void f_verify_transmittal_table_details() throws Exception{
		System.out.println("Start Test: Verify Transmittal Table Details");
		actl.search_verify_dynamic_table(driver, "draft");
		actl.verify_transmittal_table_count(driver, "cocolife");
		System.out.println("End Test: Verify Transmittal Table Details\n");
	}
	@Test
	public void g_proceed_to_draft_transmittal() throws Exception{
		System.out.println("Start Test: Proceed with Transmittal");
		actl.proceed_with_transmittal(driver, "cocolife", transmittal_number);
		System.out.println("End Test: Proceed with Transmittal\n");
	}
	@Test
	public void h_verify_transmittal_table_details() throws Exception{
		System.out.println("Start Test: Verify Draft Transmittal Details");
		m.verify_table_header_inpatient_hospital(driver);
		m.verify_table_header_outpatient_hospital(driver);
		m.verify_hmo_transmittal(driver,"cocolife", transmittal_number);
		actl.search_verify_dynamic_table(driver, "draft");
		actl.verify_transmittal_table_count(driver, "cocolife");
		m.verify_location_edit_transmittal(driver);
		System.out.println("End Test: Verify Draft Transmittal Details\n");
	}
	@Test
	public void i_exclude_inpatient() throws Exception{
		System.out.println("Start Test: Exclude Inpatient on Transmittal");
		atl.exclude_not_transmitted_patient(driver, "inpatient");
		actl.save_transmittal(driver, "draft", transmittal_number, "3 patient");
		atl.search_transmittal_list(driver, transmittal_number, "draft", "COCOLIFE HEALTH CARE");
		atl.verify_include_not_transmitted_patient(driver, "inpatient","validate");
		System.out.println("End Test: Exclude Inpatient on Transmittal\n");
	}
	@Test
	public void j_include_inpatient() throws Exception{
		System.out.println("Start Test: Include Inpatient on Transmittal");
		atl.include_not_transmitted_patient(driver, "inpatient");
		System.out.println("End Test: Include Inpatient on Transmittal\n");
	}
	@Test
	public void k_verify_include_inpatient() throws Exception{
		System.out.println("Start Test: Verify Inpatient on Transmittal");
		actl.save_transmittal(driver, "draft", transmittal_number,"4 patient");
		atl.search_transmittal_list(driver, transmittal_number, "draft", "COCOLIFE HEALTH CARE");
		atl.verify_include_not_transmitted_patient(driver, "inpatient","verify");
		System.out.println("End Test: Verify Inpatient on Transmittal\n");
	}
	@Test
	public void l_verify_transmittal_table_details() throws Exception{
		System.out.println("Start Test: Verify Transmittal Table Details");
		m.verify_table_header_inpatient_hospital(driver);
		m.verify_table_header_outpatient_hospital(driver);
		m.verify_location_edit_transmittal(driver);
		m.verify_hmo_transmittal(driver,"cocolife", transmittal_number);
		m.verify_table_inpatient_alphabetical(driver);
		m.verify_table_outpatient_alphabetical(driver);
		System.out.println("End Test: Verify Transmittal Table Details\n");
	}
	@Test
	public void m_exclude_outpatient() throws Exception{
		System.out.println("Start Test: Exclude Outpatient on Transmittal");
		atl.exclude_not_transmitted_patient(driver, "outpatient");
		actl.save_transmittal(driver, "draft", transmittal_number, "1 patient");
		atl.search_transmittal_list(driver, transmittal_number, "draft", "COCOLIFE HEALTH CARE");
		atl.verify_include_not_transmitted_patient(driver, "outpatient","validate");
		System.out.println("End Test: Exclude Outpatient on Transmittal\n");
	}
	@Test
	public void n_include_outpatient() throws Exception{
		System.out.println("Start Test: Include Outpatient on Transmittal");
		atl.include_not_transmitted_patient(driver, "outpatient");
		System.out.println("End Test: Include Outpatient on Transmittal\n");
	}
	@Test
	public void o_verify_include_outpatient() throws Exception{
		System.out.println("Start Test: Verify Outpatient on Transmittal");
		actl.save_transmittal(driver, "draft", transmittal_number,"4 patient");
		atl.search_transmittal_list(driver, transmittal_number, "draft", "COCOLIFE HEALTH CARE");
		atl.verify_include_not_transmitted_patient(driver, "outpatient","verify");
		System.out.println("End Test: Verify Outpatient on Transmittal\n");
	}
	@Test
	public void p_verify_transmittal_table_details() throws Exception{
		System.out.println("Start Test: Verify Transmittal Table Details");
		m.verify_table_header_inpatient_hospital(driver);
		m.verify_table_header_outpatient_hospital(driver);
		m.verify_location_edit_transmittal(driver);
		m.verify_hmo_transmittal(driver,"cocolife", transmittal_number);
		m.verify_table_inpatient_alphabetical(driver);
		m.verify_table_outpatient_alphabetical(driver);
		System.out.println("End Test: Verify Transmittal Table Details\n");
	}
	@Test
	public void q_compute_transmittal_details() throws Exception{
		System.out.println("Start Test: Compute Transmittal Amount");
		transmittal_amount = actl.compute_transmittal_table_headers_dynamic(driver, false);
		System.out.println("End Test: Compute Transmittal Amount\n");
	}
	@Test
	public void r_generate_transmittal() throws Exception{
		System.out.println("Start Test: Generate Transmittal");
		actl.click_generate_transmittal(driver, "4 patient", transmittal_number);
		System.out.println("End Test: Generate Transmittal\n");
	}
	@Test
	public void s_search_final_transmittal() throws Exception{
		System.out.println("Start Test: Search Final Transmittal");
		m.go_to_admin_home(driver);
		m.go_to_transmittal_admin(driver);
		m.check_transmittal_details(driver, transmittal_number, "COCOLIFE HEALTH CARE", transmittal_amount, false);
		atl.search_transmittal_list(driver, transmittal_number, "final", "COCOLIFE HEALTH CARE");
		System.out.println("End Test: Search Final Transmittal\n");
	}
	@Test
	public void t_verify_transmittal_table_details() throws Exception{
		System.out.println("Start Test: Verify Final Transmittal Table Details");
		m.verify_location_edit_transmittal(driver);
		m.verify_hmo_transmittal_final(driver,"cocolife", transmittal_number);
		m.verify_final_transmittal_date(driver);
		actl.search_verify_dynamic_table(driver, "final");
		actl.verify_transmittal_table_count(driver, "cocolife");
		System.out.println("End Test: Verify Final Transmittal Table Details\n");
	}
	@Test
	public void u_preview_transmittal_memo() throws Exception{
		System.out.println("Start Test: Preview Transmittal Memo");
		atl.preview_transmittal_memo(driver);
		System.out.println("End Test: Preview Transmittal Memo\n");
	}
	@Test
	public void v_logout_app() throws Exception{
		System.out.println("Start Test: Logout Admin Console");
		Logout out = new Logout();
		out.admin(driver);
		System.out.println("End Test: Logout Admin Console\n");
	}
}
